# -*- coding: utf-8 -*-

import allure
import pytest

from TestCases.boe_MultiDomesticTravelTest.boe_submit import BoeSubmit
from TestCases.common import BusinessApprove, SharingCenterApprove, ecsMyBoeList, \
    ecsUserDraft, ecsWaitDeal, BusinessApproved
from Util import logger, record, ZTCCloudAssertion, config, util
from Util.loadTestData import loadTestData as LTD


@allure.epic("费用报销单据测试")
@allure.feature("多人差旅报账单")
class TestBoeMultiDomesticTravel(ZTCCloudAssertion):
    """
    # 方法级setup、teardown前置与后置  * 类里面的在每条测试用例(方法名带test的)执行前都会去执行一次
    # 类级setup_class、teardown_class前置与后置  * 类级前置后置只打开一次就执行所有的测试用例
    # 运行的优先级：setup_class>>setup_method>setup>用例>teardown>teardown_method>>teardown_class
    """
    def setup_class(self):
        logger.info('----- 开始测试多人差旅报账单场景 -----')

    def teardown_class(self):
        util.killChromeProcess()
        logger.info('----- 多人差旅报账单场景测试完成 -----')

    @allure.description("提交-所有业务领导同意-执行定时器-共享同意-我的单据状态查验")
    @allure.title("场景1：主流程")
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe1")[0])
    @allure.severity("blocker")
    def test_MultiDomesticTravel1(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit() as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')

        with allure.step('第二步 业务领导1审批同意'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApprove()
                self.assertEqual(content, '审批成功', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

        with allure.step('第三步 业务领导2审批同意'):
            logger.info(" ----- 单据业务领导2审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader2', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApprove()
                self.assertEqual(content, '审批成功', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导2审批通过，单号：{boeNo} ----- ')

        with allure.step('第四步 共享初审审批'):
            logger.info(" ----- 单据共享初审审批开始 ----- ")
            with SharingCenterApprove(boeNo, isExit=True) as sca:
                logger.info(f" ----- 单据共享审批-初审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveChuShen()
                self.assertIn('成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-初审结束，单号：{boeNo} ----- ")

        with allure.step('第五步 共享复审审批'):
            logger.info(" ----- 单据共享复审审批开始 ----- ")
            with SharingCenterApprove(boeNo, node='review', isExit=True) as sca:
                logger.info(f" ----- 单据共享审批-复审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveFuShen()
                self.assertIn('成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-复审结束，单号：{boeNo} ----- ")
                logger.info(f' ----- 单据审批结束，单号：{boeNo} ----- ')

    @allure.description("提交-撤回-删除")
    @allure.title("场景2")
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe2")[0])
    @allure.severity("critical")
    def test_MultiDomesticTravel2(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=False) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                driver = submit.login.driver
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')

        with allure.step('第二步 提单人撤回单据'):
            logger.info(" ----- 提单人撤回单据 ----- ")
            with ecsMyBoeList(driver) as myBoeList:
                content = myBoeList.withdrawBoe(boeNo)
                self.assertEqual(content, '撤回成功', boe_data, driver)
                logger.info(f' ----- 提单人撤回单据成功，单号：{boeNo} ----- ')

        with allure.step('第三步 提单人删除单据'):
            logger.info(" ----- 提单人删除单据 ----- ")
            with ecsUserDraft(driver, isExit=True) as userDraft:
                content = userDraft.deleteBoe(boeNo)
                self.assertEqual(content, '删除成功', boe_data, driver)
                logger.info(f' ----- 提单人删除单据成功，单号：{boeNo} ----- ')

    @allure.description("提交-驳回-待我处理检查-作废-重新提交")
    @allure.title("场景3")
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe3")[0])
    @allure.severity("normal")
    def test_MultiDomesticTravel3(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=False) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                driver = submit.login.driver
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')

        with allure.step('第二步 业务领导1驳回单据'):
            logger.info(" ----- 业务领导1驳回单据 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApproveReject(config.fscNodes[0], 'UI自动化拒绝')
                self.assertEqual(content, '审批成功', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1驳回单据成功，单号：{boeNo} ----- ')

        with allure.step('第三步 提单人先作废单据再提交'):
            logger.info(" ----- 提单人先作废单据再提交 ----- ")
            with ecsWaitDeal(driver, isExit=True) as waitDeal:
                content = waitDeal.invalidBoeAndRetrySubmit(boeNo)
                self.assertEqual(content, '提交校验成功', boe_data, driver)
                logger.info(f' ----- 提单人作废并提交单据完成，单号：{boeNo} ----- ')

    @allure.description('提交-业务领导1同意-业务领导2驳回至业务领导1-业务领导2撤回-业务领导2同意')
    @allure.title('场景4')
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe4")[0])
    @allure.severity('critical')
    def test_MultiDomesticTravel4(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=True) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')

        with allure.step('第二步 业务领导1审批同意'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApprove()
                self.assertEqual(content, '审批成功', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

        with allure.step('第三步 业务领导2审批驳回至业务领导1节点'):
            logger.info(" ----- 单据业务领导2审批驳回 ----- ")
            with BusinessApprove(boeNo, 'leader2', isExit=False) as businessApprove:
                content = businessApprove.boeBusinessApproveReject(config.fscNodes[1], 'UI自动化拒绝')
                self.assertEqual(content, '审批成功', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导2审批驳回成功，单号：{boeNo} ----- ')
                driver = businessApprove.driver

        with allure.step('第四步 业务领导2撤回'):
            logger.info(" ----- 单据业务领导2审批撤回 ----- ")
            with BusinessApproved(driver=driver) as businessApproved:
                content = businessApproved.boeBusinessApproveWithdraw(boeNo)
                self.assertEqual(content, '撤回成功', boe_data, businessApproved.driver)
                logger.info(f' ----- 业务领导2审批撤回成功，单号：{boeNo} ----- ')

        with allure.step('第五步 业务领导2审批同意'):
            logger.info(" ----- 单据业务领导2审批同意 ----- ")
            with BusinessApprove(boeNo, 'leader2', driver=driver, isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApprove()
                self.assertEqual(content, '审批成功', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导2审批成功，单号：{boeNo} ----- ')

    @allure.description('提交-业务领导1打开两个标签页，一个加签，另一个同意')
    @allure.title('场景5')
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe5")[0])
    @allure.severity('normal')
    def test_MultiDomesticTravel5(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=True) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')

        with allure.step('第二步 业务领导1打开两个标签页，一个加签，另一个同意'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApproveTwoPages('加签', '同意', **config.businessParams)
                self.assertEqual(content, '审批失败', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

    @allure.description('提交-业务领导1打开两个标签页，一个加签，另一个驳回')
    @allure.title('场景6')
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe6")[0])
    @allure.severity('normal')
    def test_MultiDomesticTravel6(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=True) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')

        with allure.step('第二步 业务领导1打开两个标签页，一个加签，另一个驳回'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApproveTwoPages('加签', '驳回', **config.businessParams)
                self.assertEqual(content, '审批失败', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

    @allure.description('提交-业务领导1打开两个标签页，一个转交，另一个驳回')
    @allure.title('场景7')
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe7")[0])
    @allure.severity('normal')
    def test_MultiDomesticTravel7(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=True) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')

        with allure.step('第二步 业务领导1打开两个标签页，一个转交，另一个驳回'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApproveTwoPages('转交', '驳回', **config.businessParams)
                self.assertEqual(content, '审批失败', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

    @allure.description('提交-业务领导1打开两个标签页，一个转交，另一个同意')
    @allure.title('场景8')
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe8")[0])
    @allure.severity('normal')
    def test_MultiDomesticTravel8(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=True) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')

        with allure.step('第二步 业务领导1打开两个标签页，一个转交，另一个同意'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApproveTwoPages('转交', '同意', **config.businessParams)
                self.assertEqual(content, '审批失败', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

    @allure.description('提交-业务领导1打开两个标签页，一个挂起，另一个同意')
    @allure.title('场景9')
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe9")[0])
    @allure.severity('normal')
    def test_MultiDomesticTravel9(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=True) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')

        with allure.step('第二步 业务领导1打开两个标签页，一个挂起，另一个同意'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApproveTwoPages('挂起', '同意', **config.businessParams)
                self.assertEqual(content, '审批失败', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

    @allure.description('提交-业务领导1打开两个标签页，一个挂起，另一个驳回')
    @allure.title('场景10')
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe10")[0])
    @allure.severity('normal')
    def test_MultiDomesticTravel10(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=True) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')

        with allure.step('第二步 业务领导1打开两个标签页，一个挂起，另一个驳回'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApproveTwoPages('挂起', '驳回', **config.businessParams)
                self.assertEqual(content, '审批失败', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

    @allure.description('提交-业务领导1打开两个标签页，一个挂起，另一个加签')
    @allure.title('场景11')
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe11")[0])
    @allure.severity('normal')
    def test_MultiDomesticTravel11(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=True) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')

        with allure.step('第二步 业务领导1打开两个标签页，一个挂起，另一个加签'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApproveTwoPages('挂起', '加签', **config.businessParams)
                self.assertEqual(content, '审批失败', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

    @allure.description('提交-业务领导1打开两个标签页，一个挂起，另一个转交')
    @allure.title('场景12')
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe12")[0])
    @allure.severity('normal')
    def test_MultiDomesticTravel12(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=True) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')

        with allure.step('第二步 业务领导1打开两个标签页，一个挂起，另一个转交'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApproveTwoPages('挂起', '转交', **config.businessParams)
                self.assertEqual(content, '审批失败', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

    @allure.description('提交-业务领导1打开两个标签页，一个同意，另一个驳回')
    @allure.title('场景13')
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe13")[0])
    @allure.severity('normal')
    def test_MultiDomesticTravel13(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=True) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')

        with allure.step('第二步 业务领导1打开两个标签页，一个同意，另一个驳回'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApproveTwoPages('同意', '驳回', **config.businessParams)
                self.assertEqual(content, '审批失败', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

    @allure.description('提交-业务领导1打开两个标签页，一个转交，另一个加签')
    @allure.title('场景14')
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe14")[0])
    @allure.severity('normal')
    def test_MultiDomesticTravel14(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=True) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')

        with allure.step('第二步 业务领导1打开两个标签页，一个转交，另一个加签'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApproveTwoPages('转交', '加签', **config.businessParams)
                self.assertEqual(content, '审批失败', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

    @allure.description('提交-审批至共享复审-驳回至共享初审-驳回至开始节点，直送至我-流程结束')
    @allure.title('场景15')
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe15")[0])
    @allure.severity('critical')
    def test_MultiDomesticTravel15(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=False) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')
                submitDriver = submit.login.driver

        with allure.step('第二步 业务领导1审批同意'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApprove()
                self.assertEqual(content, '审批成功', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

        with allure.step('第三步 业务领导2审批同意'):
            logger.info(" ----- 单据业务领导2审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader2', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApprove()
                self.assertEqual(content, '审批成功', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导2审批通过，单号：{boeNo} ----- ')

        with allure.step('第四步 共享初审同意'):
            logger.info(" ----- 单据共享审批开始 ----- ")
            with SharingCenterApprove(boeNo) as sca:
                logger.info(f" ----- 单据共享审批-初审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveChuShen()
                self.assertIn('成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-初审结束，单号：{boeNo} ----- ")
                chuShenDriver = sca.driver

        with allure.step('第五步 共享复审驳回至共享初审'):
            with SharingCenterApprove(boeNo, node='review', isExit=True) as sca:
                logger.info(f" ----- 单据共享审批-复审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveFuShenReject('UI自动化拒绝')
                self.assertIn('审批成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-复审结束，单号：{boeNo} ----- ")

        with allure.step('第六步 共享初审驳回至开始节点'):
            with SharingCenterApprove(boeNo, node='review', driver=chuShenDriver) as sca:
                logger.info(f" ----- 单据共享审批-初审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveChuShenReject(config.fscNodes[0], 'UI自动化拒绝', True)
                self.assertIn('审批成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-初审结束，单号：{boeNo} ----- ")

        with allure.step('第七步 提单人再次提交单据'):
            with ecsWaitDeal(submitDriver, True) as waitDeal:
                logger.info(f" ----- 提单人在待我处理中重新提交单据，单号：{boeNo} ----- ")
                message = waitDeal.submitBoeByBoeNo(boeNo)
                self.assertIn(boe_data.expectation, message, boe_data, sca.driver)
                logger.info(f" ----- 待我处理提交单据完成，单号：{boeNo} ----- ")

        with allure.step('第八步 共享初审审批同意'):
            logger.info(" ----- 单据共享初审审批开始 ----- ")
            with SharingCenterApprove(boeNo, driver=chuShenDriver, isExit=True) as sca:
                logger.info(f" ----- 单据共享审批-初审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveChuShen()
                self.assertIn('成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-初审结束，单号：{boeNo} ----- ")

        with allure.step('第九步 共享复审审批同意'):
            logger.info(" ----- 单据共享复审审批开始 ----- ")
            with SharingCenterApprove(boeNo, node='review', isExit=True) as sca:
                logger.info(f" ----- 单据共享审批-复审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveFuShen()
                self.assertIn('成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-复审结束，单号：{boeNo} ----- ")
                logger.info(f' ----- 单据审批结束，单号：{boeNo} ----- ')

    @allure.description('提交-审批至共享复审-驳回至共享初审-驳回至业务审批节点，直送至我-流程结束')
    @allure.title('场景16')
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe16")[0])
    @allure.severity('critical')
    def test_MultiDomesticTravel16(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=True) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')

        with allure.step('第二步 业务领导1审批同意'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApprove()
                self.assertEqual(content, '审批成功', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

        with allure.step('第三步 业务领导2审批同意'):
            logger.info(" ----- 单据业务领导2审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader2', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApprove()
                self.assertEqual(content, '审批成功', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导2审批通过，单号：{boeNo} ----- ')

        with allure.step('第四步 共享初审同意'):
            logger.info(" ----- 单据共享审批开始 ----- ")
            with SharingCenterApprove(boeNo) as sca:
                logger.info(f" ----- 单据共享审批-初审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveChuShen()
                self.assertIn('成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-初审结束，单号：{boeNo} ----- ")
                chuShenDriver = sca.driver

        with allure.step('第五步 共享复审驳回至共享初审'):
            with SharingCenterApprove(boeNo, node='review', isExit=True) as sca:
                logger.info(f" ----- 单据共享审批-复审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveFuShenReject('UI自动化拒绝')
                self.assertIn('审批成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-复审结束，单号：{boeNo} ----- ")

        with allure.step('第六步 共享初审驳回至业务领导1节点'):
            with SharingCenterApprove(boeNo, driver=chuShenDriver) as sca:
                logger.info(f" ----- 单据共享审批-初审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveChuShenReject(config.fscNodes[1], 'UI自动化拒绝', True)
                self.assertIn('审批成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-初审结束，单号：{boeNo} ----- ")

        with allure.step('第七步 业务领导1审批同意'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApprove()
                self.assertEqual(content, '审批成功', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

        with allure.step('第八步 共享初审审批同意'):
            logger.info(" ----- 单据共享初审审批开始 ----- ")
            with SharingCenterApprove(boeNo, driver=chuShenDriver, isExit=True) as sca:
                logger.info(f" ----- 单据共享审批-初审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveChuShen()
                self.assertIn('成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-初审结束，单号：{boeNo} ----- ")

        with allure.step('第九步 共享复审审批同意'):
            logger.info(" ----- 单据共享复审审批开始 ----- ")
            with SharingCenterApprove(boeNo, node='review', isExit=True) as sca:
                logger.info(f" ----- 单据共享审批-复审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveFuShen()
                self.assertIn('成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-复审结束，单号：{boeNo} ----- ")
                logger.info(f' ----- 单据审批结束，单号：{boeNo} ----- ')

    @allure.description('提交-审批至共享复审-逐个驳回至开始-再次提交至流程结束')
    @allure.title('场景17')
    @pytest.mark.parametrize('boe_data', LTD.get_ymlTestData(__file__, "MultiDomesticTravelBoe17")[0])
    @allure.severity('critical')
    def test_MultiDomesticTravel17(self, boe_data):
        logger.info(f"用例名称：{boe_data.caseName}")
        with allure.step('第一步 提交单据'):
            logger.info(" ----- 多人差旅报账单提单 ----- ")
            with BoeSubmit(isExit=False) as submit:
                message = submit.submit(boe_data)
                self.assertIn(boe_data.expectation, message, boe_data, submit.login.driver)
                # 获取单号
                boeNo = record.readDataFromRecord().boeNo
                logger.info(f' ----- 单据提交成功，单号{boeNo} ----- ')
                submitDriver = submit.login.driver

        with allure.step('第二步 业务领导1审批同意'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', isExit=False) as businessApprove:
                content = businessApprove.boeBusinessApprove()
                self.assertEqual(content, '审批成功', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')
                leader1Driver = businessApprove.driver

        with allure.step('第三步 业务领导2审批同意'):
            logger.info(" ----- 单据业务领导2审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader2', isExit=False) as businessApprove:
                content = businessApprove.boeBusinessApprove()
                self.assertEqual(content, '审批成功', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导2审批通过，单号：{boeNo} ----- ')
                leader2Driver = businessApprove.driver

        with allure.step('第四步 共享初审同意'):
            logger.info(" ----- 单据共享审批开始 ----- ")
            with SharingCenterApprove(boeNo) as sca:
                logger.info(f" ----- 单据共享审批-初审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveChuShen()
                self.assertIn('成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-初审结束，单号：{boeNo} ----- ")
                chuShenDriver = sca.driver

        with allure.step('第五步 共享复审驳回至共享初审'):
            with SharingCenterApprove(boeNo, node='review') as sca:
                logger.info(f" ----- 单据共享审批-复审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveFuShenReject('UI自动化拒绝')
                self.assertIn('审批成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-复审结束，单号：{boeNo} ----- ")
                fuShenDriver = sca.driver

        with allure.step('第六步 共享初审驳回至业务领导2节点'):
            with SharingCenterApprove(boeNo, driver=chuShenDriver) as sca:
                logger.info(f" ----- 单据共享审批-初审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveChuShenReject(config.fscNodes[2], 'UI自动化拒绝')
                self.assertIn('审批成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-初审结束，单号：{boeNo} ----- ")

        with allure.step('第七步 业务领导2驳回至业务领导1节点'):
            with BusinessApprove(boeNo, 'leader2', driver=leader2Driver) as businessApprove:
                logger.info(f" ----- 业务领导2审批驳回开始，单号：{boeNo} ----- ")
                message = businessApprove.boeBusinessApproveReject(config.fscNodes[1], 'UI自动化拒绝')
                self.assertIn('审批成功', message, boe_data, sca.driver)
                logger.info(f" ----- 业务领导2审批驳回成功，单号：{boeNo} ----- ")

        with allure.step('第八步 业务领导1驳回至开始节点'):
            with BusinessApprove(boeNo, 'leader1', driver=leader1Driver) as businessApprove:
                logger.info(f" ----- 业务领导1审批驳回开始，单号：{boeNo} ----- ")
                message = businessApprove.boeBusinessApproveReject(config.fscNodes[0], 'UI自动化拒绝')
                self.assertIn('审批成功', message, boe_data, sca.driver)
                logger.info(f" ----- 业务领导1审批驳回成功，单号：{boeNo} ----- ")

        with allure.step('第九步 提单人待我处理再次提交该单据'):
            logger.info(" ----- 提单人待我处理再次提交该单据 ----- ")
            with ecsWaitDeal(submitDriver, isExit=True) as waitDeal:
                content = waitDeal.submitBoeByBoeNo(boeNo)
                self.assertIn(boe_data.expectation, content, boe_data, submitDriver)
                logger.info(f' ----- 再次提交单据完成，单号：{boeNo} ----- ')

        with allure.step('第十步 业务领导1审批同意'):
            logger.info(" ----- 单据业务领导1审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader1', driver=leader1Driver, isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApprove()
                self.assertEqual(content, '审批成功', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导1审批通过，单号：{boeNo} ----- ')

        with allure.step('第十一步 业务领导2审批同意'):
            logger.info(" ----- 单据业务领导2审批开始 ----- ")
            with BusinessApprove(boeNo, 'leader2', driver=leader2Driver, isExit=True) as businessApprove:
                content = businessApprove.boeBusinessApprove()
                self.assertEqual(content, '审批成功', boe_data, businessApprove.driver)
                logger.info(f' ----- 业务领导2审批通过，单号：{boeNo} ----- ')

        with allure.step('第十三步 共享初审审批'):
            logger.info(" ----- 单据共享初审审批开始 ----- ")
            with SharingCenterApprove(boeNo, driver=chuShenDriver, isExit=True) as sca:
                logger.info(f" ----- 单据共享审批-初审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveChuShen()
                self.assertIn('成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-初审结束，单号：{boeNo} ----- ")

        with allure.step('第十四步 共享复审审批'):
            logger.info(" ----- 单据共享复审审批开始 ----- ")
            with SharingCenterApprove(boeNo, node='review', driver=fuShenDriver, isExit=True) as sca:
                logger.info(f" ----- 单据共享审批-复审开始，单号：{boeNo} ----- ")
                message = sca.sharingCenterApproveFuShen()
                self.assertIn('成功', message, boe_data, sca.driver)
                logger.info(f" ----- 单据共享审批-复审结束，单号：{boeNo} ----- ")
                logger.info(f' ----- 单据审批结束，单号：{boeNo} ----- ')
